import 'package:flutter/material.dart';
import 'package:wallpaper/components/appbar_base.dart';

class IconPage extends StatelessWidget {
  const IconPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppbarBase(title: '所有图标'),
        body: Padding(
          padding: const EdgeInsets.all(8.0),
          child: CustomScrollView(
            slivers: [_iconList()],
          ),
        ));
  }

  Widget _iconList() {
    return SliverGrid(
      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 4,
        crossAxisSpacing: 10.0,
        mainAxisSpacing: 10.0,
      ),
      delegate: SliverChildBuilderDelegate(
        childCount: 47,
        (BuildContext context, int index) {
          return Material(
            color: Theme.of(context).colorScheme.primaryContainer,
            borderRadius: BorderRadius.circular(10),
            child: InkWell(
              borderRadius: BorderRadius.circular(10), // 设置水波纹的圆角
              onTap: () {
                // 点击逻辑
                print('点击了图标 ${index + 1}');
              },
              child: Center(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Image.asset('lib/assets/icon/${index + 1}.png', width: 30),
                    Text('图标${index + 1}'),
                  ],
                ),
              ),
            ),
          );
        },
      ),
    );
  }
}
